package com.newtribe.performance;

import java.util.* ;
/**
 * <p> </p>
 * <p>Description: Innovatation method</p>
 * <p>Copyright: Copyright (c)  newtribe innovation 2002</p>
 * <p> </p>
 * @author fuwei
 * @version 1.0
 */

public class TimeStat {
  public TimeStat() {
  }

  private static ArrayList ar = new ArrayList() ;
  public static void main(String[] argv) throws Exception {
    record();
    for (int i = 0; i < 1000000; i++) {
      HashMap m = new HashMap();
    }
    record();
    for (int i = 0; i < 1000000; i++) {
      HashMap m = new HashMap();
    }
    record();

    for (int i = 0; i < 1000000; i++) {
      HashMap m = new HashMap();
    }
    record();

    for (int i = 0; i < 1000000; i++) {
      HashMap m = new HashMap();
    }
    record();

  }
  
  static long last =System.currentTimeMillis();

  public static void record() {

    long now =System.currentTimeMillis() ;

    long diff =0 ;
  
    diff =now-last;

    last =(new Long(System.currentTimeMillis()));


    try {

      throw new Exception() ;


    }catch(Exception e ) {

      StackTraceElement[] elements  = e.getStackTrace() ;
      StackTraceElement element =elements[1] ;
      System.out.println("run cost:"+diff +"  "+element.getClassName()+":"+element.getMethodName() +" at:" +element.getLineNumber()) ;

    }



  }

}